home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / utility / sml-mode-3.3b / sml-mode.info < prev    next >
Encoding:
GNU Info File  |  1997-08-18  |  51.9 KB  |  1,336 lines  |  [TEXT/R*ch]

  1. This is Info file sml-mode.info, produced by Makeinfo version 1.67 from
  2. the input file sml-mode.texi.
  3.  
  4. 
  5. File: sml-mode.info,  Node: Top,  Next: Copying,  Prev: (dir),  Up: (dir)
  6.  
  7. SML Mode Info
  8. *************
  9.  
  10. You are looking at the top node of the Info tree documenting SML-MODE
  11. (Version 3.3). Not all functions are documented here, but those that
  12. aren't you probably won't miss. All commands and settable variables
  13. have built-in documentation, as per usual Emacs conventions.
  14.  
  15. * Menu:
  16.  
  17. * Copying::             You can copy SML mode
  18. * Introduction::        Setting things up
  19. * SML Mode::            Editing SML source
  20. * Interaction Mode::    Running ML processes
  21. * Configuration::       Menus, highlighting, setting defaults
  22. * Credits::             Credit and blame
  23.  
  24. Indexes
  25. * Command Index::       Commands you can invoke
  26. * Variable Index::      Variables you can set
  27. * Key Index::           Default keybindings
  28.  
  29. Introduction
  30. * Distribution::        What this distribution contains
  31. * Getting Started::     What to tell Emacs
  32. * Getting Help::        How Emacs can help
  33.  
  34. SML Mode
  35. * Basics::              On entering SML mode
  36. * Indentation::         Prettying SML text
  37. * Magic Insertion::     Templates and electric keys
  38. * SML Mode Defaults::   Variables controlling indentation
  39.  
  40. Interaction Mode
  41. * Running ML::          Commands to run the ML compiler in a buffer
  42. * ML Interaction::      Sending program fragments to the compiler
  43. * Tracking Errors::     Finding reported syntax errors
  44. * Process Defaults::    Setting defaults for process interaction
  45.  
  46. Configuration
  47. * Hooks::               Creating hooks
  48. * Key Bindings::        Binding commands to keys
  49. * Menus::               Taking advantage of bitmapped screens
  50. * Highlighting::        Syntax colouring
  51. * Advanced Topics::     You may need to speak Emacs Lisp
  52.  
  53. 
  54. File: sml-mode.info,  Node: Copying,  Next: Introduction,  Prev: Top,  Up: Top
  55.  
  56. Copying
  57. *******
  58.  
  59. You can freely copy, modify and redistribute SML mode because it's made
  60. available under the liberal terms of the GNU General Public License.
  61.  
  62.    GNU General Public License as published by the Free Software
  63. Foundation; either version 2, or (at your option) any later version.
  64.  
  65.    SML mode is distributed in the hope that it will be useful, but
  66. WITHOUT ANY WARRANTY; without even the implied warranty of
  67. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  68. Public License for more details.
  69.  
  70.    You should have received a copy of the GNU General Public License
  71. along with GNU Emacs; see the file COPYING. If not, write to the Free
  72. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  73.  
  74. 
  75. File: sml-mode.info,  Node: Introduction,  Next: SML Mode,  Prev: Copying,  Up: Top
  76.  
  77. Introduction
  78. ************
  79.  
  80. SML mode is a major mode for Emacs for editing Standard ML. It has some
  81. novel bugs, and some nice features:
  82.  
  83.    * Automatic indentation of sml code--a number of variables to
  84.      customise the indentation.
  85.  
  86.    * Easy insertion for commonly used templates like let, local,
  87.      signature, and structure declarations, with minibuffer prompting
  88.      for types and expressions.
  89.  
  90.    * Magic pipe insertion: `|' automatically determines if it is used
  91.      in a case or fun construct, and indents the next line as
  92.      appropriate, inserting `=>' or the name of the function.
  93.  
  94.    * Inferior shell for running ML. There's no need to leave Emacs,
  95.      just keep on editing while the compiler runs in another window.
  96.  
  97.    * Automatic "use file" in the inferior shell--you can send files,
  98.      buffers, or regions of code to the ML subprocess.
  99.  
  100.    * Menus, and syntax and keyword highlighting supported for Emacs 19
  101.      and derivatives.
  102.  
  103.    * Parsing errors from the inferior shell, and repositioning the
  104.      source--much like the next-error function used in c-mode.
  105.  
  106.    * SML mode can be easily configured to work with a number of Standard
  107.      ML compilers, and other SML based tools.
  108.  
  109. * Menu:
  110.  
  111. * Distribution::        What this distribution contains
  112. * Getting Started::     What to tell Emacs
  113. * Getting Help::        How Emacs can help
  114.  
  115. 
  116. File: sml-mode.info,  Node: Distribution,  Next: Getting Started,  Prev: Introduction,  Up: Introduction
  117.  
  118. The SML mode distribution
  119. =========================
  120.  
  121. The distribution contains several Emacs Lisp files--this is for ease of
  122. maintenance, you can concatenate them if you're careful:
  123.  
  124. `sml-mode.el'
  125.      Main file, and should work in any Emacs editor or version post
  126.      18.58--it only knows, or thinks it knows, about SML syntax and
  127.      indentation.
  128.  
  129. `sml-menus.el'
  130.      Menus to access user settable features of the mode, and for those
  131.      who prefer menus over keys under Emacs 19 and derivatives.
  132.  
  133. `sml-{hilite,font}.el'
  134.      Syntax highlighting functions to display keywords in a bold font,
  135.      comments in italics, etc., using one of Emacs' two popular syntax
  136.      colouring packages.
  137.  
  138. `sml-proc.el'
  139.      Process interaction requires the `comint' package (normally
  140.      distributed with Emacs 19 and derivatives).
  141.  
  142. `sml-{poly-ml,mosml}.el'
  143.      Auxiliary library support for Poly/ML and Moscow ML compilers.
  144.  
  145. There is also the Texinfo generated `info' file:
  146.  
  147. `sml-mode.{dvi,info}'
  148.      This file--rudimentary SML mode documentation, and
  149.  
  150. `sml-site.el'
  151.      Configuration file for system-wide installation. Read and edit
  152.      this file if you are installing SML mode for general use.
  153.  
  154. 
  155. File: sml-mode.info,  Node: Getting Started,  Next: Getting Help,  Prev: Distribution,  Up: Introduction
  156.  
  157. Getting started
  158. ===============
  159.  
  160. With luck your system administrator will have installed SML mode
  161. somewhere convenient, so all you have to do is put the line
  162.  
  163.      (require 'sml-site)
  164.  
  165. in your `.emacs' configuration file and all will be well--you can skip
  166. the rest of this getting started section. Otherwise you will need to
  167. tell Emacs where to find all the SML mode `.el' files, and when to use
  168. them. The where is addressed by locating the Lisp code on your Emacs
  169. Lisp load path--you may have to create a directory for this, say
  170. `/home/mjm/elisp', and then insert the following lines in your
  171. `/home/mjm/.emacs' file(1):
  172.  
  173.      (setq load-path (cons "/home/mjm/elisp" load-path))
  174.      (autoload 'sml-mode "sml-mode" "Major mode for editing SML." t)
  175.  
  176. The first line adjusts Emacs' internal search path so it can locate the
  177. Lisp source you have copied to that directory; the second line tells
  178. Emacs to load the code automatically when it is needed. You can then
  179. switch any Emacs buffer into SML mode by entering the command
  180.  
  181.      M-x sml-mode
  182.  
  183. It is usually more convenient to have Emacs automatically place the
  184. buffer in SML mode whenever you visit a file containing ML programs.
  185. The simplest way of achieving this is to put something like
  186.  
  187.      (setq auto-mode-alist
  188.            (append '(("\\.sml$" . sml-mode)
  189.                      ("\\.sig$" . sml-mode)
  190.                      ("\\.ML$"  . sml-mode)) auto-mode-alist))
  191.  
  192. also in your `.emacs' file. Subsequently (after a restart), any files
  193. with these extensions will be placed in SML mode buffers when you visit
  194. them.
  195.  
  196.    You may want to pre-compile the `sml-*.el' files (`M-x
  197. byte-compile-file') for greater speed--byte compiled code loads and
  198. runs somewhat faster.
  199.  
  200.    ---------- Footnotes ----------
  201.  
  202.    (1)  cf. commentary in the site initialisation file `sml-site.el'.
  203.  
  204. 
  205. File: sml-mode.info,  Node: Getting Help,  Prev: Getting Started,  Up: Introduction
  206.  
  207. Help!
  208. =====
  209.  
  210. You're reading it. Apart from the on-line info tree (`C-h i' is the
  211. Emacs key to enter the `info' system--you should follow the brief
  212. tutorial if this is unfamiliar), there are further details on specific
  213. commands in their documentation strings. Only the most useful SML mode
  214. commands are documented in the info tree: to find out more use Emacs'
  215. help facilities.
  216.  
  217.    Briefly, to get help on a specific function use `C-h f' and enter
  218. the command name. All (almost all, then) SML mode commands begin with
  219. `sml-', so if you type this and press <TAB> (for completion) you will
  220. get a list of all commands. Another way is to use `C-h a' and enter the
  221. string `sml'. This is command apropos; it will list all commands with
  222. that sub-string in their names, and any key binding they may have in
  223. the current buffer. Command apropos gives a one-line synopsis of what
  224. each command does.
  225.  
  226.    Some commands are also variables--such things are allowed in Lisp, if
  227. not in ML! *Note Command Index::, for a list of (info) documented
  228. functions. *Note Variable Index::, for a list of user settable variables
  229. to control the behaviour of SML mode.
  230.  
  231.    Before accessing this information on-line from within Emacs you may
  232. have to set the variable `sml-mode-info'. Put in your `.emacs' file
  233. something like:
  234.  
  235.      (setq sml-mode-info "/home/mjm/info/sml-mode.info")
  236.  
  237. When different from the default this variable should be a string giving
  238. the absolute name of the `.info' file. Then `C-c C-i' in SML mode
  239. (i.e., the command `M-x sml-mode-info') will bring up the manual. This
  240. help is also accessible from the menu. (Resetting this variable will
  241. not be necessary if your site administrator has been kind enough to
  242. install SML mode and its attendant documentation in the Emacs
  243. hierarchy.)
  244.  
  245. 
  246. File: sml-mode.info,  Node: SML Mode,  Next: Interaction Mode,  Prev: Introduction,  Up: Top
  247.  
  248. Editing with SML Mode
  249. *********************
  250.  
  251. Now SML mode provides just a few additional editing commands. Most of
  252. the work (*note Credit & Blame: Credits.) has gone into implementing
  253. the indentation algorithm which, if you think about it, has to be
  254. complicated for a language like ML. *Note Indentation Defaults: SML
  255. Mode Defaults, for details on how to control some of the behaviour of
  256. the indentation algorithm. Principal goodies are the `electric pipe'
  257. feature, and the ability to insert common SML forms (macros or
  258. templates).
  259.  
  260. * Menu:
  261.  
  262. * Basics::              On entering SML mode
  263. * Indentation::         Prettying SML text
  264. * Magic Insertion::     Templates and electric keys
  265. * SML Mode Defaults::   Variables controlling indentation
  266.  
  267. 
  268. File: sml-mode.info,  Node: Basics,  Next: Indentation,  Prev: SML Mode,  Up: SML Mode
  269.  
  270. On entering SML mode
  271. ====================
  272.  
  273.  - Command: sml-mode
  274.      This switches a buffer into SML mode. This is a *major mode* in
  275.      Emacs. To get out of SML mode the buffer's major mode must be set
  276.      to something else, like text-mode. *Note Getting Started::, for
  277.      details on how to set this up automatically when visiting an SML
  278.      file.
  279.  
  280.    Emacs is all hooks of course. A hook is a variable: if the variable
  281. is non-nil it binds a list of Emacs Lisp functions to be run in some
  282. order (usually left to right). You can customise SML mode with these
  283. hooks:
  284.  
  285.  - Hook: sml-mode-hook
  286.      Default: `nil'
  287.  
  288.      This is run every time a new SML mode buffer is created (or if you
  289.      type `M-x sml-mode'). This is one place to put your preferred key
  290.      bindings. *Note Configuration::, for some examples.
  291.  
  292.  - Hook: sml-load-hook
  293.      Default: `'sml-mode-version'
  294.  
  295.      Another, maybe better, place for key bindings. This hook is only
  296.      run when SML mode is loaded into Emacs. *Note Configuration::.
  297.  
  298.  - Command: sml-mode-version
  299.      Prints the current version of SML mode in the mini-buffer, in case
  300.      you need to know. I've put it on `sml-load-hook' so you can easily
  301.      tell which version of SML mode you are running.
  302.  
  303. 
  304. File: sml-mode.info,  Node: Indentation,  Next: Magic Insertion,  Prev: Basics,  Up: SML Mode
  305.  
  306. Automatic indentation
  307. =====================
  308.  
  309. ML is a complicated language to parse, let alone compile. The
  310. indentation algorithm is a little wooden (for some tastes), and the best
  311. advice is not to fight it! There are several variables that can be
  312. adjusted to control the indentation algorithm (*note Customising SML
  313. Mode: SML Mode Defaults., below).
  314.  
  315.  - Command: sml-indent-line
  316.      Key: <TAB>
  317.  
  318.      This command indents the current line. If you set the indentation
  319.      of the previous line by hand, `sml-indent-line' will indent
  320.      relative to this setting.
  321.  
  322.  - Command: sml-indent-region
  323.      Key: `C-M-\'
  324.  
  325.      Indent the current region. Be patient if the region is large (like
  326.      the whole buffer).
  327.  
  328.  - Command: sml-back-to-outer-indent
  329.      Key: `M-<TAB>'
  330.  
  331.      Unindents the line to the next outer level of indentation.
  332.  
  333.    Further indentation commands that Emacs provides (generically, for
  334. all modes) that you may like to recall:
  335.  
  336.    - `M-x newline-and-indent'
  337.  
  338.      On <LFD> by default.  Insert a newline, then indent according to
  339.      the major mode. *Note Indentation for Programs: (emacs)Program
  340.      Indent, for details.
  341.  
  342.    - `M-x indent-rigidly'
  343.  
  344.      On `C-x <TAB>' by default.  Moves all lines in the region right by
  345.      its argument (left, for negative arguments). *Note Indentation:
  346.      (emacs)Indentation.
  347.  
  348.    - `M-x indent-for-comment'
  349.  
  350.      On `M-;' by default.  Indent this line's comment to comment
  351.      column, or insert an empty comment. *Note Comment Commands:
  352.      (emacs)Comment Commands.
  353.  
  354.    - `M-x indent-new-comment-line'
  355.  
  356.      On `M-<LFD>' by default.  Break line at point and indent,
  357.      continuing comment if within one.  *Note Multi-Line Comments:
  358.      (emacs)Multi-Line Comments.
  359.  
  360.    As with other language modes, `M-;' gives you a comment at the end
  361. of the current line. The column where the comment starts is determined
  362. by the variable `comment-column'--default is 40, but it can be changed
  363. with `set-comment-column' (on `C-x ;' by default).
  364.  
  365. 
  366. File: sml-mode.info,  Node: Magic Insertion,  Next: SML Mode Defaults,  Prev: Indentation,  Up: SML Mode
  367.  
  368. Electric features
  369. =================
  370.  
  371. Electric keys are generally pretty irritating, so those provided by SML
  372. mode are fairly muted. The only truly electric key is `;', and this has
  373. to be enabled to take effect.
  374.  
  375.  - Command: sml-electric-pipe
  376.      Key: `M-|'
  377.  
  378.      When the point is in a `case' statement this opens a new line,
  379.      indents and inserts `| =>' leaving point just before the double
  380.      arrow; if the enclosing construct is a `fun' declaration, the
  381.      newline is indented and the function name copied at the
  382.      appropriate column. Generally, try it whenever a `|' is
  383.      wanted--you'll like it!
  384.  
  385.  - Command: sml-electric-semi
  386.      Key: `;'
  387.  
  388.      Just inserts a semi-colon, usually. The behaviour of this command
  389.      is governed by the variable `sml-electric-semi-mode'.
  390.  
  391.  - Command, Variable: sml-electric-semi-mode
  392.      Default: `nil'
  393.  
  394.      If this variable is `nil', `sml-electric-semi' just inserts a
  395.      semi-colon, otherwise it inserts a semi-colon and a newline, and
  396.      indents the newline for SML. The command toggles the value of the
  397.      variable; if you give the command a prefix argument (i.e., `C-u M-x
  398.      sml-electric-semi-mode') this always disables the electric effect
  399.      of `;'.
  400.  
  401.  - Command: sml-insert-form
  402.      Key: `C-c <RET>'
  403.  
  404.      Interactive short-cut to insert common ML forms (a.k.a. macros, or
  405.      templates). Recognised forms are `let', `local', `case', `abstype',
  406.      `datatype', `signature', `structure', and `functor'. Except for
  407.      `let' and `local', these will prompt for appropriate parameters
  408.      like functor name and signature, etc.. This command prompts in the
  409.      mini-buffer, with completion.
  410.  
  411.      By default `C-c <RET>' will insert at point, with the indentation
  412.      of the current column; if you give a prefix argument (i.e., `C-u
  413.      C-c <RET>') the command will insert a newline first, indent, and
  414.      then insert the template.
  415.  
  416.    `sml-insert-form' is also extensible: see *Note Configuration:: for
  417. further details.
  418.  
  419. 
  420. File: sml-mode.info,  Node: SML Mode Defaults,  Prev: Magic Insertion,  Up: SML Mode
  421.  
  422. Indentation defaults
  423. ====================
  424.  
  425. Several variables try to control the indentation algorithm and other
  426. features of SML mode. For these user settable variables there is
  427. generally a function of the same name that does the job--look for them
  428. in the menu under *Format/Mode Variables*.
  429.  
  430.  - Command, Variable: sml-indent-level
  431.      Default: `4'
  432.  
  433.      This variable controls the block indentation level. The command
  434.      prompts for a numeric value unless a numeric prefix is provided
  435.      instead. For example `M-2 M-x sml-indent-level' will set the
  436.      variable to 2 without prompting.
  437.  
  438.  - Command, Variable: sml-pipe-indent
  439.      Default: `-2'
  440.  
  441.      This variable adjusts the indentation level for lines that begin
  442.      with a `|' (after any white space). The extra offset is usually
  443.      negative.  The command prompts for a numeric value unless a
  444.      numeric prefix is provided instead.
  445.  
  446.  - Variable: sml-paren-lookback
  447.      Default: `1000'
  448.  
  449.      The number of characters the indentation algorithm searches for an
  450.      opening parenthesis. 1000 characters is about 30-40 lines; larger
  451.      values mean slower indentation. If the value of the variable is
  452.      `nil' this means the indentation algorithm won't look back at all.
  453.  
  454.    If the default values are not acceptable you can set these variables
  455. permanently in your `.emacs' file. *Note Configuration::, for details
  456. and examples. Three further variables control the behaviour of
  457. indentation.
  458.  
  459.  - Command, Variable: sml-case-indent
  460.      Default: `nil'
  461.  
  462.      How to indent `case' expressions:
  463.  
  464.           If `t':                             If `nil':
  465.           case expr                           case expr of
  466.             of exp1 => ...                        exp1 => ...
  467.              | exp2 => ...                      | exp2 => ...
  468.  
  469.      The first seems to be the standard in SML/NJ. The second is the
  470.      (nicer?) default.
  471.  
  472.  - Command, Variable: sml-nested-if-indent
  473.      Default: `nil'
  474.  
  475.      Nested `if-then-else' expressions have the following indentation
  476.      depending on the value.
  477.  
  478.           If `t':                           If `nil':
  479.           if exp1 then exp2                 if exp1 then exp2
  480.           else if exp3 then exp4            else if exp3 then exp4
  481.           else if exp5 then exp6                 else if exp5 then exp6
  482.                else exp7                              else exp7
  483.  
  484.  - Command, Variable: sml-type-of-indent
  485.      Default: `t'
  486.  
  487.      Determines how to indent `let', `struct', etc..
  488.  
  489.           If `t':                           If `nil':
  490.           fun foo bar = let                 fun foo bar = let
  491.                             val p = 4           val p = 4
  492.                         in                  in
  493.                             bar + p             bar + p
  494.                         end                 end
  495.  
  496.      `sml-type-of-indent' will not have any effect if the starting
  497.      keyword is the first word on the line.
  498.  
  499. 
  500. File: sml-mode.info,  Node: Interaction Mode,  Next: Configuration,  Prev: SML Mode,  Up: Top
  501.  
  502. Running ML under Emacs
  503. **********************
  504.  
  505. The most useful feature of SML mode is that it provides a convenient
  506. interface to the compiler. How serious users of ML put up with a
  507. teletype interface to the compiler is beyond me... but perhaps there
  508. are other interfaces to compilers that require one to part with serious
  509. money. Such remarks can quickly become dated--in this case, let's hope
  510. so!
  511.  
  512.    Anyway, SML mode provides an interaction mode, `inferior-sml-mode',
  513. where the compiler runs in a separate buffer in a window or frame of
  514. its own. You can use this buffer just like a terminal, but it's usually
  515. more convenient to mark some text in the SML mode buffer and have Emacs
  516. communicate with the sub-process. The features discussed below are
  517. syntax-independent, so they should work with a wide range of ML-like
  518. tools and compilers. *Note Process Defaults::, for some hints.
  519.  
  520.    `inferior-sml-mode' is a specialisation of the `comint' package that
  521. comes with GNU Emacs and GNU XEmacs.
  522.  
  523. * Menu:
  524.  
  525. * Running ML::          Commands to run the ML compiler in a buffer
  526. * ML Interaction::      Sending program fragments to the compiler
  527. * Tracking Errors::     Finding reported syntax errors
  528. * Process Defaults::    Setting defaults for process interaction
  529.  
  530. 
  531. File: sml-mode.info,  Node: Running ML,  Next: ML Interaction,  Prev: Interaction Mode,  Up: Interaction Mode
  532.  
  533. Starting the compiler
  534. =====================
  535.  
  536. Start your favourite ML compiler with the command
  537.  
  538.      M-x sml
  539.  
  540. This creates a process interaction buffer that inherits some key
  541. bindings from SML mode and from `comint' (*note Shell Mode:
  542. (emacs)Shell Mode.). Starting the ML compiler adds some functions to
  543. SML mode buffers so that program text can be communicated between
  544. editor and compiler (*note ML Interaction::.).
  545.  
  546.    The name of the ML compiler is the first thing you should know how to
  547. specify:
  548.  
  549.  - Variable: sml-program-name
  550.      Default: `"sml"'
  551.  
  552.      The program to run as ML. You might need to specify the full path
  553.      name of the program.
  554.  
  555.  - Variable: sml-default-arg
  556.      Default: `""'
  557.  
  558.      Useful for Poly/ML users who may supply a database file, or others
  559.      who have wrappers for setting various options around the command
  560.      to run the compiler. Moscow ML people might set this to `"-P
  561.      full"', etc..
  562.  
  563.    The variable `sml-program-name' is a string holding the name of the
  564. program *as you would type it at the shell*. You can always choose a
  565. program different to the default by invoking
  566.  
  567.      C-u M-x sml
  568.  
  569. With the prefix argument Emacs will prompt for the command name and any
  570. command line arguments to pass to the compiler. Thereafter Emacs will
  571. use this new name as the default, but for a permanent change you should
  572. set this in your `.emacs' with, e.g.:
  573.  
  574.      (setq sml-program-name "nj-sml")
  575.  
  576. You probably shouldn't set this in `sml-mode-hook' because that will
  577. interfere if you occasionally run a different compiler (e.g., `poly' or
  578. `hol90').
  579.  
  580.  - Command: sml
  581.      Launches ML as an inferior process in another buffer; if an ML
  582.      process already exists, just switch to the process buffer. A
  583.      prefix argument allows you to edit the command line to specify the
  584.      program, and any command line options.
  585.  
  586.  - Hook: inferior-sml-mode-hook
  587.      Default: `nil'
  588.  
  589.      `M-x sml' runs `comint-mode-hook' and `inferior-sml-mode-hook'
  590.      hooks in that order, but *after* the compiler is started. Use
  591.      `inferior-sml-mode-hook' to set any `comint' buffer-local
  592.      configurations for SML mode you like.
  593.  
  594.  - Hook: inferior-sml-load-hook
  595.      Default: `nil'
  596.  
  597.      This hook is analogous to `sml-load-hook' and is run just after the
  598.      code for `inferior-sml-mode' is loaded into Emacs. Use this to set
  599.      process defaults, and preferred key bindings for the interaction
  600.      buffer.
  601.  
  602.  - Command: switch-to-sml
  603.      Key: `C-c C-s'
  604.  
  605.      Switch from the SML buffer to the interaction buffer. By default
  606.      point will be placed at the end of the process buffer, but a
  607.      prefix argument will leave point wherever it was before. If you
  608.      try `C-c C-s' before an ML process has been started, you'll just
  609.      get an error message to the effect that there's no current process
  610.      buffer.
  611.  
  612.  - Variable: sml-dedicated-frame
  613.      Default: `(if window-system t nil)'
  614.  
  615.      If `t' this indicates to `switch-to-sml' and other functions that
  616.      the interaction buffer where ML is running will be displayed on its
  617.      own, dedicated frame; otherwise the interaction buffer will appear
  618.      on the current frame, splitting the window if necessary. The
  619.      default means SML mode will try and use a dedicated frame if you
  620.      are running Emacs under X Windows (say), but not otherwise. The
  621.      variable `sml-display-frame-alist' configures the dedicated frame's
  622.      appearance (`C-h v sml-display-frame-alist' for details).
  623.  
  624.  - Command: sml-cd
  625.      When started, the ML compiler's default working directory is the
  626.      current buffer's default directory. This command allows the working
  627.      directory to be changed, if the compiler can do this. The variable
  628.      `sml-cd-command' specifies the compiler command to invoke (*note
  629.      Process Defaults::.).
  630.  
  631. 
  632. File: sml-mode.info,  Node: ML Interaction,  Next: Tracking Errors,  Prev: Running ML,  Up: Interaction Mode
  633.  
  634. Speaking to the compiler
  635. ========================
  636.  
  637. Several commands are defined for sending program fragments to the
  638. running compiler. Each of the following commands takes a prefix argument
  639. that will switch the input focus to the process buffer afterwards
  640. (leaving point at the end of the buffer):
  641.  
  642.  - Command: sml-load-file
  643.      Key: `C-c C-l'
  644.  
  645.      Send a `use file' command to the current ML process. The variable
  646.      `sml-use-command' is used to define the correct template for the
  647.      command to invoke (*note Process Defaults::.). The default file is
  648.      the file associated with the current buffer, or the last file
  649.      loaded if you are in the interaction buffer.
  650.  
  651.  - Command: sml-send-region
  652.      Key: `C-c C-r'
  653.  
  654.      Send the current region of text in the SML buffer.
  655.      `sml-send-region-and-go' is a similar command for you to bind in
  656.      SML mode if you wish: it'll send the region and then switch-to-sml.
  657.  
  658.  - Command: sml-drag-region
  659.      Key: `M-S-down-mouse-1'
  660.  
  661.      It's sometimes irritating to do all that `C-@' and `C-c C-r' stuff
  662.      to send regions to the ML process, so if you are running Emacs
  663.      under X Windows (say) you can do the same job by holding down both
  664.      the <SHIFT> and <META> keys, and dragging with mouse button one
  665.      over the region. This will temporarily highlight the region as you
  666.      move the mouse, like `mouse-drag-region' (i.e., `down-mouse-1'),
  667.      and send the highlighted text straight into the jaws of the ML
  668.      compiler.
  669.  
  670.      If you only click the mouse button, instead of dragging, the
  671.      region of text sent to the compiler is delimited by the current
  672.      position of point and the place where you click the mouse. In
  673.      neither case will the command set the region.
  674.  
  675.  - Command: sml-send-buffer
  676.      Key: `C-c C-b'
  677.  
  678.      Send the contents of the current buffer to ML.
  679.  
  680.    By and large, Emacs can nowadays quite happily send large chunks of
  681. text to its subprocesses (`comint' does input splitting). However, it is
  682. still probably safest(1) to send larger program fragments to ML via the
  683. temporary file mechanism. This, for `sml-send-region' and other SML
  684. mode commands that use it in some way, takes advantage of the ML
  685. compiler's ability to open a file and compile the contents by making a
  686. temporary file of the indicated text. Two variables of interest are:
  687.  
  688.  - Variable: sml-temp-threshold
  689.      Default: `0'
  690.  
  691.      Determines what constitutes a large program fragment. A value of
  692.      512, say, will declare half a kilobyte a suitable threshold and
  693.      larger fragments will be sent via a temporary file. A value of 0
  694.      means *all* text is sent via a temporary file; the value `nil'
  695.      inhibits the temporary file mechanism altogether.
  696.  
  697.  - Variable: sml-temp-file
  698.      Default: `(make-temp-name "/tmp/ml")'
  699.  
  700.      A string that gives the name of the temporary file to use. This
  701.      default ensures Emacs will invent a unique name for this purpose
  702.      for use throughout the rest of the editing session. Only one
  703.      temporary file is used.
  704.  
  705.    Another reason, you might well say *the reason*, for using the
  706. temporary file mechanism is that error messages reported by the ML
  707. compiler (*note Tracking Errors::.) are generally useless to SML mode
  708. unless a real file is associated with the input (an embedded *use file*
  709. will count as a real file). Of course, this all rather depends on the
  710. compiler producing sensible error messages, and on SML mode being able
  711. to parse them.
  712.  
  713.    ---------- Footnotes ----------
  714.  
  715.    (1)  XEmacs 19.11 users are warned that changing the default
  716. `sml-temp-threshold' may well cause XEmacs to hang; they seem to have
  717. fixed the problem in 19.12 and above.
  718.  
  719. 
  720. File: sml-mode.info,  Node: Tracking Errors,  Next: Process Defaults,  Prev: ML Interaction,  Up: Interaction Mode
  721.  
  722. Finding errors
  723. ==============
  724.  
  725. SML mode provides one customisable function for locating the source
  726. position of errors reported by the compiler. This should work whether
  727. you type `use "puzzle.sml";' into the interaction buffer, or use one of
  728. the mechanisms provided for sending programs directly to the
  729. compiler--*note ML Interaction::..
  730.  
  731.  - Command: sml-next-error
  732.      Key: `C-c`'
  733.  
  734.      Jump to the source location of the next error reported by the
  735.      compiler.  If the function bound to `sml-error-parser' returns a
  736.      range of character positions for the location of the error in the
  737.      source file, `sml-next-error' will put the mark at the end of the
  738.      range with point at the beginning; it may also highlight the
  739.      region specified; it will also echo the one-line text of the error
  740.      message if the error parser returns one.(1)
  741.  
  742.      If you enter `C-u C-c`' instead, the command (a.k.a.
  743.      `sml-skip-errors') skips past all the remaining error messages and
  744.      removes any error overlay in the current buffer. Note that `C-c`'
  745.      also works in the ML interaction buffer (by default).
  746.  
  747.  - Variable, Command: sml-error-overlay
  748.      Default: `t'
  749.  
  750.      Legal default values for this buffer-local variable are `t' and
  751.      `nil'. The variable attains a local value in each SML mode buffer
  752.      when the default is `t'; in this case the local value is an
  753.      overlay (or *extent* in XEmacs speak), and this means
  754.      `sml-next-error' will highlight errors in the buffer when it can.
  755.      If the default is `nil' it stays that way and `sml-next-error'
  756.      will not highlight anything, ever.
  757.  
  758.      The command `M-x sml-error-overlay' will set the overlay around the
  759.      current region, or remove the overlay if a prefix argument is given
  760.      (i.e., `C-u M-x sml-error-overlay' removes the overlay, but this
  761.      functionality can be accessed from the menu to save typing).
  762.  
  763.    Note that SML mode will usually locate errors relative to the start
  764. of the last major program fragment sent to the compiler (via
  765. `sml-load-file', etc.), but if you don't use the temporary file
  766. mechanism to communicate text to the ML process (*note Process
  767. Defaults::.), errors will generally not be located at all.
  768.  
  769.    ---------- Footnotes ----------
  770.  
  771.    (1)  Does `sml-error-parser' return these nice things? The answer is
  772. complicated! *Note Advanced Topics::, and the docstring `C-h v
  773. sml-error-parser'.
  774.  
  775. 
  776. File: sml-mode.info,  Node: Process Defaults,  Prev: Tracking Errors,  Up: Interaction Mode
  777.  
  778. Process defaults
  779. ================
  780.  
  781. The process interaction code is independent of the compiler used,
  782. deliberately, so SML mode will work with a variety of ML compilers and
  783. ML-based tools. There are therefore a number of variables that may need
  784. to be set correctly before SML mode can speak to the compiler.  Things
  785. are by default set up for Standard ML of New Jersey, but switching to a
  786. new system is quite easy--very easy if you are using Poly/ML or Moscow
  787. ML as these are supported by libraries bundled with SML mode.
  788.  
  789.  - Variable: sml-use-command
  790.      Default: `"use \"%s\""'
  791.  
  792.      Use file command template. Emacs will replace the `%s' with a file
  793.      name. Note that Emacs requires double quote characters inside
  794.      strings to be quoted with a backslash.
  795.  
  796.  - Variable: sml-cd-command
  797.      Default: `"System.Directory.cd \"%s\""'
  798.  
  799.      Compiler command to change the working directory. Not all ML
  800.      systems support this feature (well, Edinburgh (core) ML didn't),
  801.      but they should.
  802.  
  803.  - Variable: sml-prompt-regexp
  804.      Default: `"^[\-=] *"'
  805.  
  806.      Matches the ML compiler's prompt: `comint' uses this for various
  807.      purposes.
  808.  
  809.    To customise error reportage for different ML compilers you need to
  810. set two further variables before `sml-next-error' can be useful:
  811.  
  812.  - Variable: sml-error-regexp
  813.      Default: `sml-smlnj-error-regexp'
  814.  
  815.      This is the regular expression for matching the start of an error
  816.      message. The default matches the Standard ML of New Jersey
  817.      compiler's Error and Warning messages. If you don't want stop at
  818.      Warnings try, for example:
  819.             "^[-= ]*.+:[0-9]+\\.[0-9]+.+Error:"
  820.      If you're using Edinburgh (core) ML try `"^Parse error:"'.
  821.  
  822.  - Variable: sml-error-parser
  823.      Default: `'sml-smlnj-error-parser'
  824.  
  825.      The function that actually parses the error message. Again, the
  826.      default is for SML/NJ. If you need to change this you may have to
  827.      do a little Emacs Lisp programming.
  828.  
  829.    Note that bundled libraries supply an `sml-mosml-error-parser' and
  830. an `sml-poly-ml-error-parser', and set all the attendant compiler
  831. variables. *Note Advanced Topics::, for tips on how to program your own
  832. compiler extension to SML mode.
  833.  
  834. 
  835. File: sml-mode.info,  Node: Configuration,  Next: Credits,  Prev: Interaction Mode,  Up: Top
  836.  
  837. Configuration Summary
  838. *********************
  839.  
  840. This (sort of pedagogic) section gives more information on how to
  841. configure SML mode: menus, key bindings, hooks and highlighting are
  842. discussed, along with a few other random topics. First, though, the
  843. auxiliary files `sml-poly-ml.el' and `sml-mosml.el' define defaults for
  844. these popular (?) ML compilers--Poly/ML and Moscow ML, respectively.
  845. One way to setup SML mode to use Moscow ML is to add to your `.emacs':
  846.  
  847.      (defun my-mosml-setup () "Initialise inferior SML mode for Moscow ML."
  848.        (load-library "sml-mosml.el")
  849.        (setq sml-program-name "/home/mjm/mosml/bin/mosml"))
  850.      (add-hook 'inferior-sml-load-hook 'my-mosml-setup)
  851.  
  852. which creates a hook function `my-mosml-setup' and adds it to
  853. `inferior-sml-load-hook' so that the defaults for `sml-error-regexp'
  854. and its ilk (*note Process Defaults::.) are correctly initialised; I
  855. have to set `sml-program-name' explicitly here because that directory
  856. isn't on my (Unix) PATH. The story is similar if you use Poly/ML.
  857. Note, by the way, that order matters here: the `load-library' call
  858. comes first because the default for `sml-program-name' in
  859. `sml-mosml.el' is just `"mosml"'.
  860.  
  861.    The auxiliary libraries bundled with SML mode define commands
  862. `sml-mosml' and `sml-poly-ml' (there's also an `sml-smlnj' for
  863. uniformity); these commands prompt for suitable values for
  864. `sml-program-name' and `sml-default-arg' before starting the compiler
  865. and setting the other process defaults. A prefix argument will give you
  866. the builtin defaults with no questions asked.
  867.  
  868. * Menu:
  869.  
  870. * Hooks::               Creating them
  871. * Key Bindings::        Binding commands to keys
  872. * Menus::               Taking advantage of bitmapped screens
  873. * Highlighting::        Syntax colouring
  874. * Advanced Topics::     You may need to speak Emacs Lisp
  875.  
  876. 
  877. File: sml-mode.info,  Node: Hooks,  Next: Key Bindings,  Prev: Configuration,  Up: Configuration
  878.  
  879. Hooks
  880. =====
  881.  
  882. One way to set SML mode variables (*note Indentation Defaults: SML Mode
  883. Defaults.), and other defaults, is through the `sml-mode-hook' in your
  884. `.emacs'. A simple example:
  885.  
  886.      (defun my-sml-mode-hook () "Local defaults for SML mode"
  887.        (setq sml-indent-level 2)        ; conserve on horizontal space
  888.        (setq words-include-escape t)    ; \ loses word break status
  889.        (setq indent-tabs-mode nil))     ; never ever indent with tabs
  890.      (add-hook 'sml-mode-hook 'my-sml-mode-hook)
  891.  
  892. The body of `my-sml-mode-hook' is a sequence of bindings. In this case
  893. it is not really necessary to set `sml-indent-level' in a hook because
  894. this variable is global (most SML mode variables are). With similar
  895. effect:
  896.  
  897.      (setq sml-indent-level 2)
  898.  
  899. anywhere in your `.emacs' file (but probably on `sml-load-hook'). The
  900. variable `indent-tabs-mode' is automatically made local to the current
  901. buffer whenever it is set explicitly, so it *must* be set in a hook if
  902. you always want SML mode to behave like this. The same goes for the
  903. buffer-local `sml-error-overlay'; since this is globally `t' by default,
  904. set it globally `nil' if you never want errors highlighted:
  905.  
  906.      (setq-default sml-error-overlay nil)
  907.  
  908. Again, on `sml-load-hook' would probably be the best place.
  909.  
  910.    Another hook is `inferior-sml-mode-hook'. This can be used to
  911. control the behaviour of the interaction buffer through various
  912. variables meaningful to `comint'-based packages:
  913.  
  914.      (defun my-inf-sml-mode-hook () "Local defaults for inferior SML mode"
  915.        (add-hook 'comint-output-filter-functions 'comint-truncate-buffer)
  916.        (setq      comint-scroll-show-maximum-output t)
  917.        (setq      comint-input-autoexpand nil))
  918.      (add-hook 'inferior-sml-mode-hook 'my-inf-sml-mode-hook)
  919.  
  920. Again, the body is a sequence of bindings. Unless you run several ML
  921. compilers simultaneously under one Emacs, this hook will normally only
  922. get run once. You might want to look up the documentation (`C-h v' and
  923. `C-h f') for these buffer-local `comint' things.
  924.  
  925. 
  926. File: sml-mode.info,  Node: Key Bindings,  Next: Menus,  Prev: Hooks,  Up: Configuration
  927.  
  928. Key bindings
  929. ============
  930.  
  931. Customisation (in Emacs) usually entails putting favourite commands on
  932. easily remembered keys. Two `keymaps' are defined in SML mode: one is
  933. effective in program text buffers (`sml-mode-map') and the other is
  934. effective in interaction buffers (`inferior-sml-mode-map').  The
  935. initial design ensures that (many of) the default key bindings from the
  936. former keymap will also be available in the latter (e.g., `C-c`').
  937.  
  938.    Type `C-h m' in an SML mode buffer to find the default key bindings
  939. (and similarly in an ML interaction buffer), and use the hooks provided
  940. to install your preferred key bindings. Given that the keymaps are
  941. global (variables):
  942.  
  943.      (defun my-sml-load-hook () "Global defaults for SML mode"
  944.        (define-key   sml-mode-map "\C-cd" 'sml-cd)
  945.        (define-key   sml-mode-map "\C-co" 'sml-error-overlay))
  946.      (add-hook 'sml-load-hook 'my-sml-load-hook)
  947.  
  948. This has the effect of binding `sml-cd' to the key `C-c d', and the
  949. command `sml-error-overlay' to the key `C-c o'. If you want the same
  950. behaviour from `C-c d' in the ML buffer:
  951.  
  952.      (defun my-inf-sml-load-hook () "Global defaults for inferior SML mode"
  953.        (define-key inferior-sml-mode-map "\C-cd" 'sml-cd)
  954.        ;; NB. for SML/NJ '96
  955.        (setq sml-cd-command "OS.FileSys.chDir \"%s\""))
  956.      (add-hook 'inferior-sml-load-hook 'my-inf-sml-load-hook)
  957.  
  958.    There is nothing to stop you rebuilding the entire keymap for SML
  959. mode and the ML interaction buffer in your `.emacs' of course: SML mode
  960. won't define `sml-mode-map' or `inferior-sml-mode-map' if you have
  961. already done so.
  962.  
  963. 
  964. File: sml-mode.info,  Node: Menus,  Next: Highlighting,  Prev: Key Bindings,  Up: Configuration
  965.  
  966. Menus
  967. =====
  968.  
  969. Menus are useful for fiddling with mode defaults and finding out what
  970. keys commands are on if you are forgetful (not all commands are listed
  971. in the menu). For menus to appear in the menu bar under GNU Emacs or GNU
  972. XEmacs, the editor must be able to find one of two packages--i.e., one
  973. or both must be on your `load-path'. The first option is `easymenu'
  974. which is distributed with GNU Emacs. Easy!
  975.  
  976.    The second option is `auc-menu' which was written by Per Abrahamsen
  977. and distributed with AUCTeX, but it is independently available from the
  978. IESD lisp archive(1) at Aalborg. You'll also find `auc-menu' is
  979. available from the LCD archive(2), the main repository for all Emacs
  980. Lisp. The advantage of `auc-menu' is that it works with XEmacs too.
  981.  
  982.    Notice that certain menu entries are not illuminated at first--these
  983. are generally functions that depend on there being an ML process running
  984. with which to communicate.
  985.  
  986.    ---------- Footnotes ----------
  987.  
  988.    (1)  `ftp://sunsite.auc.dk/packages/auctex/'
  989.  
  990.    (2)
  991. `ftp://archive.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive/misc/'
  992.  
  993. 
  994. File: sml-mode.info,  Node: Highlighting,  Next: Advanced Topics,  Prev: Menus,  Up: Configuration
  995.  
  996. Syntax colouring
  997. ================
  998.  
  999. Highlighting is very handy for picking out keywords in the program text,
  1000. spotting misspelled kewyords, and, if you have Emacs' `ps-print'
  1001. package installed (you usually do these days), obtaining pretty, even
  1002. colourful code listings--quite properly for your colourful ML programs.
  1003.  
  1004.    Various highlight (hilite, if you spell real bad!) packages are
  1005. available for GNU Emacs 19, and GNU XEmacs. SML mode can use either
  1006. `hilit19' which only comes with Emacs, or `font-lock' which is the
  1007. package of choice with XEmacs. If you are not familiar with these
  1008. highlight packages you'll have to check their sources for installation
  1009. guidelines, etc..
  1010.  
  1011.    Use `sml-load-hook' to tell Emacs which scheme you prefer for SML
  1012. mode. For example:
  1013.  
  1014.      (add-hook 'sml-load-hook '(lambda () (require 'sml-font)))
  1015.  
  1016. This ensures the SML extensions to `font-lock' will be available once
  1017. SML mode loads (from `sml-font.el'--if you prefer `hilit19' you should
  1018. `(require 'sml-hilite)' instead.
  1019.  
  1020.    The variable `sml-font-lock-extra-keywords' is for further
  1021. customising `font-lock' for SML mode. The value of the variable should
  1022. be a list of strings, each of which is a regular expression that should
  1023. match the desired keyword exactly. Here's an example:
  1024.  
  1025.      (setq sml-font-lock-extra-keywords
  1026.            '("\\babstraction\\b" "\\bfunsig\\b" "=>" "::"))))
  1027.  
  1028. The `\b' marks a word boundary, according to the syntax table defined
  1029. for SML mode. Backslash must be quoted inside a string.  *Note Regexps:
  1030. (emacs)Regexps, for a summary of Emacs' regular expression syntax.
  1031.  
  1032.    Finally, the variable `sml-font-lock-auto-on' can be used to control
  1033. whether or not `font-lock' should be enabled by default in SML mode
  1034. buffers; it is enabled by default. The `sml-hilite' package is
  1035. customisable, but only with regard to colour changes.
  1036.  
  1037. 
  1038. File: sml-mode.info,  Node: Advanced Topics,  Prev: Highlighting,  Up: Configuration
  1039.  
  1040. Advanced Topics
  1041. ===============
  1042.  
  1043. * Menu:
  1044.  
  1045. * Forms::    These forms are bloody useless; can't we have better ones?
  1046. * Indents::  I hate that indentation algorithm; can't I suppress it?
  1047. * Frames::   The dedicated frame for ML is too huge; can it be made smaller?
  1048. * Multi ML:: Can SML mode handle more than one compiler running at once?
  1049. * Other ML:: What needs to be done to support other ML compilers?
  1050.  
  1051. 
  1052. File: sml-mode.info,  Node: Forms,  Next: Indents,  Prev: Advanced Topics,  Up: Advanced Topics
  1053.  
  1054.            *These forms are bloody useless; can't we have better ones?*
  1055.  
  1056. You can indeed. `sml-insert-form' is extensible so all you need to do
  1057. is create the macros yourself. Define a *keybord macro* (`C-x ('
  1058. <something> `C-x )') and give it a suitable name:
  1059. `sml-addto-forms-alist' prompts for a name, say `NAME', and binds the
  1060. macro `sml-form-NAME'. Thereafter `C-c <RET> NAME' will insert the
  1061. macro at point, and `C-u C-c <RET> NAME' will insert the macro after a
  1062. `newline-and-indent'. If you want to keep your macros from one editing
  1063. session to the next, go to your `.emacs' file and call
  1064. `insert-kbd-macro'; you'll need to add `NAME' to `sml-forms-alist'
  1065. permanently yourself:
  1066.  
  1067.      (defun my-sml-load-hook () "Global defaults for SML mode"
  1068.        ;; whatever else you do
  1069.        (setq sml-forms-alist (cons '("NAME") sml-forms-alist)))
  1070.  
  1071.    If you want to create templates like `case' that prompt for
  1072. parameters you'll have to do some Lisp programming. The `tempo' package
  1073. looks like a good stating point. You can always overwrite your own
  1074. macros, but the builtin forms for `let', etc., can't be overwritten.
  1075.  
  1076. 
  1077. File: sml-mode.info,  Node: Indents,  Next: Frames,  Prev: Forms,  Up: Advanced Topics
  1078.  
  1079.               *I hate that indentation algorithm; can't I suppress it?*
  1080.  
  1081. Ah, yes, a common complaint. It's actually very easy to use SML mode
  1082. without the troublesome `sml-indent-line':
  1083.  
  1084.      (defun my-sml-load-hook () "Global defaults for SML mode"
  1085.        ;; whatever else you do
  1086.        (fset 'sml-indent-line 'ignore))
  1087.  
  1088. though `indent-relative-maybe' may conceivable be more useful than
  1089. `ignore'.
  1090.  
  1091. 
  1092. File: sml-mode.info,  Node: Frames,  Next: Multi ML,  Prev: Indents,  Up: Advanced Topics
  1093.  
  1094.       *The dedicated frame for ML is too huge; can it be made smaller?*
  1095.  
  1096. Of course, you just have to modify the frame parameters. The variable
  1097. `sml-display-frame-alist' can be defined explicitly in your `.emacs';
  1098. the default is a frame of 80 columns by 24 lines, and the icon name
  1099. will be the same as the ML interaction buffer's name--something like
  1100. `*mosml*'. I like a small, tidy font for this frame so I
  1101.  
  1102.      (setq sml-display-frame-alist
  1103.            (cons '(font . "7x14") sml-display-frame-alist))
  1104.  
  1105. in my `inferior-sml-load-hook'. If you want fewer lines, try:
  1106.  
  1107.      (setcdr (assoc 'height sml-display-frame-alist) 15)
  1108.  
  1109. or something.
  1110.  
  1111. 
  1112. File: sml-mode.info,  Node: Multi ML,  Next: Other ML,  Prev: Frames,  Up: Advanced Topics
  1113.  
  1114.           *Can SML mode handle more than one compiler running at once?*
  1115.  
  1116. The question is whether you can! See the `sml-buffer' variable's
  1117. on-line help (`C-h v sml-buffer'). Note that the SML mode compiler
  1118. variables (*note Process Defaults::.) are all buffer-local, so you can
  1119. even switch between different ML compilers, not just different
  1120. invocations of the same one. Well, you *can*.
  1121.  
  1122. 
  1123. File: sml-mode.info,  Node: Other ML,  Prev: Multi ML,  Up: Advanced Topics
  1124.  
  1125.                  *What needs to be done to support other ML compilers?*
  1126.  
  1127. Not that much really, at least not to create minimal support. The
  1128. interface between SML mode and the compiler is determined by the
  1129. variables `sml-use-command', `sml-cd-command', `sml-prompt-regexp'
  1130. (which are easy to get right), and `sml-error-regexp', and
  1131. `sml-error-parser' (which are more tricky).  The general template to
  1132. follow in setting this up is in the files `sml-{poly-ml,mosml}.el'.
  1133. These rules will not change, I hope:
  1134.  
  1135.    * `sml-next-error' uses `sml-error-regexp' to locate the start of
  1136.      the next error report in the ML interaction buffer (P)
  1137.  
  1138.    * `sml-next-error' calls `sml-error-parser', passing P, and expects
  1139.      up to five return values in this order:
  1140.  
  1141.        1. file name in which the error occurs (F)
  1142.  
  1143.        2. start line of the error (L > 0)
  1144.  
  1145.        3. start column of the error (C)
  1146.  
  1147.        4. an Emacs Lisp expression to be `eval''d at (L,C) in F (EOE)
  1148.  
  1149.        5. the actual text of the one-line error report (MSG)
  1150.  
  1151.    * `sml-error-parser' can assume that P is the start of the next
  1152.      error message that the user is interested in--since she defines
  1153.      this point by defining `sml-error-regexp'.
  1154.  
  1155.    * What `sml-error-parser' returns is a list. In the event of
  1156.      problems, I foresee the following needs:
  1157.  
  1158.         - if the file is the standard input, return `("std_in" L C)'
  1159.  
  1160.         - if the file cannot be inferred, return `(nil L C)'
  1161.  
  1162.         - if L=0, or the start cannot be inferred, return `(F nil C)'
  1163.  
  1164.         - if the start column cannot be inferred, return `(F L 1)'
  1165.  
  1166.    There's no need to return anything else. However, if you do want the
  1167. errorful text in F highlighted you should return a simple Lisp
  1168. expression in the fourth argument that'll compute the region. EOE will
  1169. be called with point at character (L,C) in F, and should move point to
  1170. the end of the errorful text. In fact, EOE can actually do anything you
  1171. wish, but in the simplest cases it'll just `(forward-char 45)', or
  1172.  
  1173.      (progn (forward-line 4) (forward-char 37))
  1174.  
  1175. etc.. If it does more, make sure it leaves point at the end of the
  1176. region in F--use `save-excursion' if switching buffers.  MSG, if
  1177. returned, will be echoed in the minibuffer.
  1178.  
  1179. 
  1180. File: sml-mode.info,  Node: Credits,  Next: Command Index,  Prev: Configuration,  Up: Top
  1181.  
  1182. Credit & Blame
  1183. **************
  1184.  
  1185. SML Mode was written originally by Lars Bo Nielsen for Emacs 18.5n;
  1186. later hacked for comint by Olin Shivers (who called it ml-mode); much
  1187. later hacked by myself because it didn't seem to work... Fritz Knabe
  1188. brilliantly posted the `hilit19' and `font-lock' functions on the net.
  1189. Lars probably would recognise much of what remains, yet now there're
  1190. menus, syntax highlighting, support for various ML compilers, Texinfo
  1191. (hey!), and more than a little hope it'll work with a variety of Emacs
  1192. 19s. But there are still things to do. Lars wrote:
  1193.      *The indentation algorithm still can be fooled. I don't know if it
  1194.      will ever be 100% right, as this means it will have to actually
  1195.      parse all of the buffer up to the actual line [...].*
  1196.  
  1197. This is still the main cause of grief; SML's syntax is a nightmare for
  1198. Emacs modes, and of course opinions vary about proper indentation. But
  1199. there may be something we can do...
  1200.  
  1201. 
  1202. File: sml-mode.info,  Node: Command Index,  Next: Variable Index,  Prev: Credits,  Up: Top
  1203.  
  1204. Command Index
  1205. *************
  1206.  
  1207. * Menu:
  1208.  
  1209. * inferior-sml-mode:                     Interaction Mode.
  1210. * sml:                                   Running ML.
  1211. * sml-back-to-outer-indent:              Indentation.
  1212. * sml-buffer:                            Multi ML.
  1213. * sml-case-indent:                       SML Mode Defaults.
  1214. * sml-cd:                                Running ML.
  1215. * sml-drag-region:                       ML Interaction.
  1216. * sml-electric-pipe:                     Magic Insertion.
  1217. * sml-electric-semi:                     Magic Insertion.
  1218. * sml-error-overlay:                     Tracking Errors.
  1219. * sml-indent-level:                      SML Mode Defaults.
  1220. * sml-indent-line:                       Indentation.
  1221. * sml-indent-region:                     Indentation.
  1222. * sml-insert-form:                       Magic Insertion.
  1223. * sml-load-file:                         ML Interaction.
  1224. * sml-mode:                              Basics.
  1225. * sml-mode-info:                         Getting Help.
  1226. * sml-mode-version:                      Basics.
  1227. * sml-nested-if-indent:                  SML Mode Defaults.
  1228. * sml-next-error:                        Tracking Errors.
  1229. * sml-pipe-indent:                       SML Mode Defaults.
  1230. * sml-send-buffer:                       ML Interaction.
  1231. * sml-send-region:                       ML Interaction.
  1232. * sml-send-region-and-go:                ML Interaction.
  1233. * sml-skip-errors:                       Tracking Errors.
  1234. * sml-type-of-indent:                    SML Mode Defaults.
  1235. * switch-to-sml:                         Running ML.
  1236.  
  1237. 
  1238. File: sml-mode.info,  Node: Variable Index,  Next: Key Index,  Prev: Command Index,  Up: Top
  1239.  
  1240. Variable Index
  1241. **************
  1242.  
  1243. * Menu:
  1244.  
  1245. * inferior-sml-load-hook:                Running ML.
  1246. * inferior-sml-mode-hook:                Running ML.
  1247. * sml-buffer:                            Multi ML.
  1248. * sml-case-indent:                       SML Mode Defaults.
  1249. * sml-cd-command:                        Process Defaults.
  1250. * sml-dedicated-frame:                   Running ML.
  1251. * sml-default-arg:                       Running ML.
  1252. * sml-display-frame-alist:               Running ML.
  1253. * sml-electric-semi-mode:                Magic Insertion.
  1254. * sml-error-overlay:                     Tracking Errors.
  1255. * sml-error-parser:                      Process Defaults.
  1256. * sml-error-regexp:                      Process Defaults.
  1257. * sml-font-lock-auto-on:                 Highlighting.
  1258. * sml-font-lock-extra-keywords:          Highlighting.
  1259. * sml-indent-level:                      SML Mode Defaults.
  1260. * sml-load-hook:                         Basics.
  1261. * sml-mode-hook:                         Basics.
  1262. * sml-mode-info:                         Getting Help.
  1263. * sml-nested-if-indent:                  SML Mode Defaults.
  1264. * sml-paren-lookback:                    SML Mode Defaults.
  1265. * sml-pipe-indent:                       SML Mode Defaults.
  1266. * sml-program-name:                      Running ML.
  1267. * sml-prompt-regexp:                     Process Defaults.
  1268. * sml-temp-file:                         ML Interaction.
  1269. * sml-temp-threshold:                    ML Interaction.
  1270. * sml-type-of-indent:                    SML Mode Defaults.
  1271. * sml-use-command:                       Process Defaults.
  1272.  
  1273. 
  1274. File: sml-mode.info,  Node: Key Index,  Prev: Variable Index,  Up: Top
  1275.  
  1276. Key Index
  1277. *********
  1278.  
  1279. * Menu:
  1280.  
  1281. * ;:                                     Magic Insertion.
  1282. * <LFD>:                                 Indentation.
  1283. * <TAB>:                                 Indentation.
  1284. * C-c <RET>:                             Magic Insertion.
  1285. * C-c C-b:                               ML Interaction.
  1286. * C-c C-i:                               Getting Help.
  1287. * C-c C-l:                               ML Interaction.
  1288. * C-c C-r:                               ML Interaction.
  1289. * C-c C-s:                               Running ML.
  1290. * C-c`:                                  Tracking Errors.
  1291. * C-M-\:                                 Indentation.
  1292. * C-x ;:                                 Indentation.
  1293. * C-x <TAB>:                             Indentation.
  1294. * M-;:                                   Indentation.
  1295. * M-<LFD>:                               Indentation.
  1296. * M-<TAB>:                               Indentation.
  1297. * M-S-down-mouse-1:                      ML Interaction.
  1298. * M-|:                                   Magic Insertion.
  1299.  
  1300.  
  1301. 
  1302. Tag Table:
  1303. Node: Top103
  1304. Node: Copying1813
  1305. Node: Introduction2622
  1306. Node: Distribution4066
  1307. Node: Getting Started5366
  1308. Node: Getting Help7297
  1309. Node: SML Mode9157
  1310. Node: Basics9994
  1311. Node: Indentation11325
  1312. Node: Magic Insertion13412
  1313. Node: SML Mode Defaults15517
  1314. Node: Interaction Mode18528
  1315. Node: Running ML19881
  1316. Node: ML Interaction23788
  1317. Node: Tracking Errors27568
  1318. Node: Process Defaults30093
  1319. Node: Configuration32381
  1320. Node: Hooks34296
  1321. Node: Key Bindings36426
  1322. Node: Menus38104
  1323. Node: Highlighting39293
  1324. Node: Advanced Topics41229
  1325. Node: Forms41717
  1326. Node: Indents42929
  1327. Node: Frames43418
  1328. Node: Multi ML44151
  1329. Node: Other ML44631
  1330. Node: Credits46940
  1331. Node: Command Index47983
  1332. Node: Variable Index49633
  1333. Node: Key Index51287
  1334. 
  1335. End Tag Table
  1336.